#docs-sidebar {
  margin-bottom: 30px;

  // fallback styles for gridless browsers
  overflow-x: hidden;
  @supports (display: grid) {
    overflow-x: visible;
  }

  // Re-using the .nav class name on lists means we inherit some
  // unfortunate behavior from Bootstrap, so reset all that.
  .nav {
    ul, li, a {
      float: none;
      position: static;
      padding: 0;
    }
    ul { display: block; }
    li { display: list-item; }
    a { display: inline; }
  }

  // hide an outdated implementation of expand/collapse link
  a.subnav-toggle {
    display: none;
  }

  a#mobile-skip {
    color: $body-link-color;
  }

  #sidebar-header-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(90px, auto) 32px; // match #inner-header-grid
    margin-bottom: 16px;

    margin-top: 20px;

    h3, h4 {
      grid-column: 1/2;
      grid-row: 1/2;
      align-self: self-end;
      line-height: 26px; // align baseline w/ H1 in inner
    }

    #sidebar-controls {
      grid-column: 1/2;
      grid-row: 2/3;
      align-self: self-start;
    }
  }

  h3,
  h4 {
    margin-top: 0;
    margin-bottom: 0;
    a {
      color: $body-link-color;
    }
  }

  %sidebar-link {
    color: $sidebar-link-color;
    word-wrap: break-word;
    overflow-wrap: break-word;

    &:focus,
    &:hover {
      background-color: transparent;
      color: $sidebar-link-color-hover;
    }
  }

  div#sidebar-controls {
    box-sizing: border-box;
    position: relative;
    .glyphicon-search {
      position: absolute;
      top: 7px;
      left: 7px;
      opacity: .7;
      z-index: -1;
    }
    #filter-close {
      position: absolute;
      top: 3px;
      right: 3px;
      opacity: .7;
      z-index: 1;
      border: none;
      background: transparent;
      padding: 4px;
    }
    input {
      font-size: 0.8rem;
      height: 100%;
      margin-bottom: 1px;
      padding-left: 28px;
      background: transparent;
    }
    @media (pointer: coarse) {
      input {
        font-size: 16px;
      }
      #filter-close {
        top: 7px;
      }
      .glyphicon-search {
        top: 11px;
      }
    }
    #sidebar-buttons button {
      font-variant-caps: all-small-caps;
      color: #666;
      display: inline-block;
      border: none;
      background: transparent;

      &:first-child {
        min-width: 6em;
      }
    }
  }

  ul.nav.docs-sidenav {
    display: block;
    padding-bottom: 15px;
    margin-top: 10px;

    li {
      padding: 0 0 11px 0;
      display: grid;
      grid-template-columns: auto 1fr;
      grid-template-rows: auto auto;
      grid-template-areas: "marker name"
                           "subnav subnav";
      align-items: start;
      grid-column-gap: .4em;

      a {
        @extend %sidebar-link;
        grid-area: name;
        max-width: 100%;
        min-width: 0; // grid parent can shrink it

        // fallback styles for gridless browsers
        padding-left: .4em;
        display: table-cell;
        @supports (display: grid) {
          padding-left: 0;
          display: inline;
        }
      }

      &:before {
        grid-area: marker;
        text-align: center;

        color: $sidebar-link-color-active;
        content: '\2022';
        font-size: 0.938rem;
        opacity: 0.4;

        // fallback styles for gridless browsers
        display: table-cell;
        @supports (display: grid) {
          display: inline;
        }
      }

      &.has-subnav {
        cursor: pointer;
        &:before {
          content: '\276F';
          transition: transform .1s linear;
        }
        &.active:before {
          transform: rotate(90deg);
          transform-origin: 50% .83em;
        }
      }

      &.current > a {
        color: $sidebar-link-color-active;
      }
      &.active {
        // Open nested navigations
        > ul.nav {
          display: block;
        }
        &:before {
          opacity: 1;
        }
      }

    }

    // subnav
    ul.nav-hidden {
      display: none;
    }
    ul.nav {
      grid-area: subnav;
      padding-top: 10px;
      padding-left: 10px;

      li {
        margin-left: 10px;
      }
    }
  }
}
